package threadLock.threadBasics.interrupt;

/**
 * 根据打断标记中断线程
 * 打断之后 线程并不会立即终止
 */
public class ThreadInterrupt {

    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(() -> {
            while (!Thread.currentThread().isInterrupted()){
                System.out.println(Thread.currentThread()+" hello");
            }
        });
        thread.start();
        Thread.sleep(1000);
        System.out.println("main thread interrupt thread");
        thread.interrupt();
        thread.join();
        System.out.println("main is over");
    }

}
